// File Name: rs485_macros.h
// Author: kukukukuku~
// Date: 2024-12-20

#ifndef __RS485_MACROS_H
#define __RS485_MACROS_H

#define RS485_MODE_GPIO_PORT                GPIOD
#define RS485_MODE_GPIO_PIN                 GPIO_PIN_4

#define RS485_TX_GPIO_PORT                  GPIOD
#define RS485_TX_GPIO_PIN                   GPIO_PIN_5

#define RS485_RX_GPIO_PORT                  GPIOD
#define RS485_RX_GPIO_PIN                   GPIO_PIN_6


#define RS485_USART                         USART1
#define RS485_USART_BAUDRATE                (115200)
#define RS485_USART_MODE                    USART_MODE_TX_RX
#define RS485_USART_DATA_BIT                USART_WORD_LEN_8B
#define RS485_USART_STOP_BIT                USART_STOP_BIT_1
#define RS485_USART_PARITY_BIT              USART_PARITY_NONE
#define RS485_USART_RX_IRQ                  USART1_RX_IRQn
#define RS485_USART_RX_IRQ_HANDLE           USART1_RX_IRQHandler


#define RS485_TX_BUFFER_LEN                 (64)
#define RS485_RX_BUFFER_LEN                 (64)


#define RS485_SET_MODE_TO_SEND              GPIO_SetBit(RS485_MODE_GPIO_PORT, RS485_MODE_GPIO_PIN)
#define RS485_SET_MODE_TO_RECEIVE           GPIO_ClearBit(RS485_MODE_GPIO_PORT, RS485_MODE_GPIO_PIN)

#endif //__RS485_MACROS_H
